﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;

namespace BenchMark
{
    [MemoryDiagnoser]
    [Orderer(BenchmarkDotNet.Order.SummaryOrderPolicy.FastestToSlowest)]
    [RankColumn]
    public class BenchmarkPractice
    {
        [Params(4, 130)]
        public int Count { get; set; }

        [Benchmark(Baseline =true)]
        public List<int> WithoutInit()
        {
            var res=new List<int>();
            for (int i = 0; i < Count; i++)
                res.Add(i);
            return res;
            
        }

        [Benchmark]
        public List<int> WithInit()
        {
            var res = new List<int>(Count);
            for (int i = 0; i < Count; i++)
                res.Add(i);
            return res;
        }

        [Benchmark]
        public List<int> WithLinq()
        {
            return Enumerable.Range(0, Count).ToList();
        }


    }
}
